package nthu.web.model.business.persistence;

import java.util.List;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;

import nthu.web.controller.ResourceController;


@SuppressWarnings("serial")
public abstract class ResourceDao<R> extends HttpServlet {
	
	@SuppressWarnings("unchecked")
	public R getModel(HttpServletRequest request) {
		return (R) request.getAttribute(ResourceController.MODEL_ATTRIBUTE_NAME);
	}	
	
	public void setModel(HttpServletRequest request, R resource) {
		request.setAttribute(ResourceController.MODEL_ATTRIBUTE_NAME, resource);
	}
	
	public void setModel(HttpServletRequest request, List<R> resources) {
		request.setAttribute(ResourceController.MODEL_ATTRIBUTE_NAME, resources);
	}

}

